package com.mi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mi.entity.MyPages;
import com.mi.entity.ProductCategoryEntity;
import com.mi.entity.UserEntity;
import com.mi.mapper.ProductCategoryMapper;
import com.mi.service.ProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@com.alibaba.dubbo.config.annotation.Service
public class ProductCategoryServiceImpl implements ProductCategoryService {

    @Autowired(required = false)
    ProductCategoryMapper productCategoryMapper;

    //根基条件查询产品类别
    @Override
    public List<ProductCategoryEntity> queryProductsInfo(ProductCategoryEntity pce) {
        return productCategoryMapper.queryProductsInfo(pce);
    }

    //查询所有的产品类别
    @Override
    public List<ProductCategoryEntity> queryProductsRank() {
        return productCategoryMapper.queryProductsRank();
    }

    /**
     * 查询产品分类
     * @param productCategoryEntity
     * @return
     */
    public List<ProductCategoryEntity> queryProductCategorys(ProductCategoryEntity productCategoryEntity){
        return productCategoryMapper.queryProductCategorys(productCategoryEntity);
    }

    /**
     * 查询单个产品分类
     * @param productCategoryEntity
     * @return
     */
    public ProductCategoryEntity  queryProductCategory(ProductCategoryEntity productCategoryEntity){
        List<ProductCategoryEntity> productCategoryEntities = productCategoryMapper.queryProductCategorys(productCategoryEntity);
        if (productCategoryEntities==null||productCategoryEntities.size()==0){
            return null;
        }
        return productCategoryEntities.get(0);
    }

    /**
     * 修改产品分类
     * @param productCategoryEntity
     * @return
     */
    public boolean updProductCategory(ProductCategoryEntity productCategoryEntity){
        return productCategoryMapper.updProductCategory(productCategoryEntity);
    }

    /**
     * 删除产品分类
     * @param ids
     * @return
     */
    public boolean delProductCategory(String[] ids){
        return productCategoryMapper.delProductCategory(ids);
    }

    @Override
    public boolean addProductCategory(ProductCategoryEntity productCategoryEntity) {
        return productCategoryMapper.addProductCategory(productCategoryEntity);
    }

    /**
     * 更改产品分类状态
     * @param productCategoryEntity
     * @return
     */
    public boolean updProductCategoryStatus(ProductCategoryEntity productCategoryEntity){
        return productCategoryMapper.updProductCategoryStatus(productCategoryEntity);
    }

}
